<!DOCTYPE HTML>
<html>
<head>
    {include file="layout:_meta" /}
    <title>意见反馈</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    首页 <span class="c-gray en">&gt;</span>
    意见反馈

    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div id="table" class="page-container">
    <div class="text-c">
        <input type="text" class="input-text"  v-model="search.searchval" style="width:250px" placeholder="昵称/内容">
        <button type="submit" v-on:click="btnSearch()" class="btn btn-success" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </div>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            反馈内容标签 <button v-on:click="adminAdd()" class="btn btn-primary">新键</button>
        </span>
        <span class="r">共有数据：<strong>{{count}}</strong> 条</span></div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr class="text-c">
            <th width="25"><input type="checkbox" @click="selectAll"></th>

            <th width="300">内容</th>
            <!--ctime-->
            <th width="150">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr class="text-c" v-for="(item,index)  in lists">
            <td><input type="checkbox" :value="index" v-model="selectArr"></td>
            <td>{{item.content}} </td>
        <td class="f-14 product-brand-manage">
            <a style="text-decoration:none" v-bind:data-id="item.id" v-on:click="adminEdit($event,item.id,index)"  href="javascript:;" title="编辑">
                <i class="Hui-iconfont"> &#xe623; </i> </a>

            <a style="text-decoration:none" class="ml-5" v-on:click="datadel(this,item.id,index)" href="javascript:;" title="删除">
                <i class="Hui-iconfont">
                    <font style="vertical-align: inherit;"><font style="vertical-align: inherit;"></font></font>
                </i></a>
        </td>
        </tr>
        </tbody>
    </table>
    <!--vueJS分页---start-->
    <div class="pagination">
        <ul>
            <li v-if="current>1"><a v-on:click="current--,pageClick()">上一页</a></li>
            <li v-if="current==1"><a class="banclick">上一页</a></li>
            <li v-for="index in indexs"  v-bind:class="{ 'active': current == index}">
                <a v-on:click="btnClick(index)">{{ index }}</a>
            </li>
            <li v-if="current!=total"><a v-on:click="current++,pageClick()">下一页</a></li>
            <li v-if="current == total"><a class="banclick">下一页</a></li>
            <li><a>共<i>{{total}}</i>页</a></li>
        </ul>
    </div>
    <!--vueJS分页---end-->
</div>
<!--_footer 作为公共模版分离出去-->
{include file="layout:_footer" /}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->

<!--<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>-->
<script type="text/javascript">
    var models = {
        selectArr:[],
        count:0,
        lists: [],//表格数据
        total:1, //总页数
        current:1,  //当前页码
        search:{

        }   //搜索框
    };

    var app_model = new Vue({
        el: "#table",
        data: models,
        mounted: function () {
        },
        methods: {
            //添加按钮
            adminAdd:function () {
                var url = "{:url('feedbacktag/set')}";
                admin_add('添加',url,'800','500');
            },
            //编辑
            adminEdit: function (event) {
                var _this = $(event.currentTarget);
                var id = _this.attr('data-id');
                var url = "{:url('feedbacktag/set')}" + "?id=" + id +"&pageno="+this.current;
                admin_edit('编辑', url,'800','500');
            },
            //详情
            adminInfo: function (event) {
                var _this = $(event.currentTarget);
                var id = _this.attr('data-id');
                var url = "{:url('feedbacktag/info')}" + "?id=" + id +"&pageno="+this.current;
                admin_edit('详情', url,'800','500');
            },
            //删除按钮
            btnDel: function (event, index) {
                var _this = $(event.currentTarget);
                var id = _this.attr('data-id');
                admin_del("{:url('feedbacktag/remove')}", _this, id, index);
            },
            //全选
            selectAll(event) {
                var _this = this;
                console.log(event.currentTarget.checked)
                if (!event.currentTarget.checked) {
                    _this.selectArr = [];
                } else { //实现全选
                    _this.selectArr = [];
                    _this.lists.forEach(function(item, i) {
                        _this.selectArr.push(i);
                    });
                }
            },
            //部分删除
            datadel:function (ele,delid,index) {
                var len = this.lists.length;
                var ids = [];
                var arridx = [];
                if (delid) {
                    ids.push(delid);
                    arridx.push(index);
                }
                // for (var i = 0; i < len; i++) {
                //     if (this.selectArr[i]>=0) {
                //         let idx = this.selectArr[i];
                //         arridx.push(idx);
                //         ids.push(this.lists[idx].id);
                //     }
                // }

                admin_alldel("{:url('feedbacktag/remove')}", this, JSON.stringify(ids), arridx);
                this.selectArr = [];
            },
            //上一页,下一页翻页
            pageClick: function(){
                var url = "{:url('feedbacktag/index')}"
                initTable(url,this.current,this.search);
            },

            //点击页码
            btnClick: function(data){
                if(data != this.current){
                    this.current = data;
                    var url = "{:url('feedbacktag/index')}"
                    initTable(url,this.current,this.search);
                }
            },
            //搜索框搜索
            btnSearch:function () {
                initTable("{:url('feedbacktag/index')}",this.current,this.search);
            },
            // 身份
           Status: function($status){
                $content = '未知 ';
                switch ($status) {
                    case  0:
                        $content = '审核中'; // 0 1正常
                        break;
                    case 1 :
                        $content = '正常';
                        break;
                }
                return $content;
            },

            //用户详情
            showinfo:function(event,$userid){
                console.log($userid);
            },
            gettime:function (nS) {
                    return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
            },
            // 通过 审核
            userpass:function (event,id,index) {
                console.log(index);
                layer.confirm('确认要审核通过吗？',function(){
                    util.post("{:url('feedbacktag/pass')}",{id:id},function (data) {
                        if(data.status==true){
                          app_model.lists[index].status = 1;
                        }
                        layer.msg(data.message,{icon:1,time:1000});
                    });
                });
            },

        },

        //分页
        computed: {
            indexs: function () {
                var left = 1;
                var right = this.total;
                var ar = [];
                if (this.total >= 5) {
                    if (this.current > 3 && this.current < this.total - 2) {
                        left = this.current - 2;
                        right =left + 4;
                    } else {
                        if (this.current <= 3) {
                            left = 1;
                            right = 5;
                        } else {
                            right = this.total;
                            left = this.total - 4;
                        }
                    }
                }
                while (left <= right) {
                    ar.push(left);
                    left++;
                }
                return ar
            }
        },
        mounted:{
            // 渲染完成后的操作；

        }
    });

    //初始化数据表格
    var url = "{:url('feedbacktag/index')}" ;
    initTable(url, {$pageno});
</script>
</body>
</html>
